package com.wf.service;

import com.github.pagehelper.PageHelper;
import com.wf.dao.UserinfoMapper;
import com.wf.entity.Userinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserinfoService {
    @Autowired
    private UserinfoMapper userinfoMapper;

    public List<Userinfo> getAllByPage(Userinfo Userinfo) {
        if (Userinfo.getPage() != null && Userinfo.getRows() != null) {
            PageHelper.startPage(Userinfo.getPage(), Userinfo.getRows());
        }
        return userinfoMapper.selectAll();
    }
    public List<Userinfo> select(Userinfo Userinfo) {
        return userinfoMapper.select(Userinfo);
    }
    public Userinfo getById(Integer id) {
        return userinfoMapper.selectByPrimaryKey(id);
    }

    public void deleteById(Integer id) {
        userinfoMapper.deleteByPrimaryKey(id);
    }

    public void save(Userinfo country) {
        if (country.getId() != null) {
            userinfoMapper.updateByPrimaryKey(country);
        } else {
            userinfoMapper.insert(country);
        }
    }

}
